package top.bug.blog.controller.front;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.bug.blog.annotation.RateLimit;
import top.bug.blog.common.Result;
import top.bug.blog.entity.po.SysNotice;
import top.bug.blog.entity.vo.home.StatistiscVO;
import top.bug.blog.service.HomeService;
import top.bug.blog.service.SysNoticeService;

import javax.annotation.Resource;
import java.util.List;

import static top.bug.blog.enums.RateLimitEnum.QUERY_LIMIT;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 前台-首页模块
 */
@Api(tags = "首页相关接口")
@RestController
@RequestMapping("/api/home")
public class HomeController {
    @Resource
    private HomeService homeService;
    @Resource
    private SysNoticeService noticeService;

    @GetMapping("/statistisc")
    @ApiOperation("获取首页统计数据")
    @RateLimit(strategyEnum = QUERY_LIMIT)
    public Result<StatistiscVO> statistisc() {
        return Result.success(homeService.getHomeStatistisc());
    }

    @GetMapping("/getAllNotices")
    @ApiOperation("获取首页公告")
    @RateLimit(strategyEnum = QUERY_LIMIT)
    public Result<List<SysNotice>> getAllNotices() {
        return Result.success(noticeService.getAllNotices());
    }
}